<?php
/*
 * planning/select-template.phtml
 */
?>
<?php
$list	 = $this->list;
$count	 = count($list);
?>
<?php if ($count > 0): ?>
    <?php foreach ($list as $tpl): ?>
	<div class="empl-full vert-olive">
	    <a href='#' class='tpl-apply' data-num='<?php echo $tpl->template ?>' style='display: block; width: 100%'>
		<?php echo $tpl->libelle ?>
	    </a>
	</div>
    <?php endforeach; ?>
<?php else: ?>
    <div class="empl-full gris-beige">Aucun Planning Type disponible</div>
<?php endif; ?>
<div class='empl-half btn-success' style='float: right; margin-top: 10px; padding: 5px '>
    <a href="<?php echo $this->url('RHX/default', array('controller'	 => 'template', 'action'	 => 'index')) ?>" style='display: block; width: 100%; text-align: center'>
	Gestion Planning Type
    </a>
</div>

<form id='form' action='<?php echo $this->url('RHX/default', array('controller'	 => 'planning', 'action'	 => 'apply')) ?>' method='post'>
    <input type='hidden' name='site' value='<?php echo $this->site_id ?>'>
    <input type='hidden' name='periode_id' value='<?php echo $this->periode_id ?>'>
    <input type='hidden' name='semaine_id' value='<?php echo $this->semaine_id ?>'>
    <input type='hidden' name='template' value='<?php echo $this->template ?>' id='template'>
</form>

<script type='text/javascript'>
    $(document).ready(function() {
	// Click sur un Template
	$('.tpl-apply').click(function(event) {
	    event.preventDefault();
	    num = $(this).attr('data-num');
	    $('#template').val(num);
	    $('#form').submit();
	});
    });
</script>
